from PIL import Image
import cairosvg
import io
import os

# SVG 转 ICO
svg_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "3d.png")
ico_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "3d.ico")

# 将 SVG 转换为 PNG
png_data = cairosvg.svg2png(url=svg_path, output_width=256, output_height=256)

# 从 PNG 数据创建图像
img = Image.open(io.BytesIO(png_data))

# 保存为 ICO
img.save(ico_path, format="ICO", sizes=[(16, 16), (32, 32), (48, 48), (64, 64), (128, 128), (256, 256)])

print(f"已将 {svg_path} 转换为 {ico_path}")